<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>js-to-go</title>
    <script type="application/javascript">
        function clearMessage() {
            document.getElementById("message").innerHTML = "";
        }

        function writeMessage(data) {
            let message = document.getElementById("message");
            message.innerHTML = message.innerHTML + data + "<br>"
        }

        //ipc.on函数有2个参数
        //参数1 事件名        必填    string类型
        //参数2 回调函数      非必填   function类型, go传递的参数
        ipc.on('js-on-event-demo', function (p1, p2, p3) {
            writeMessage("js-on-event-demo Go传递过来的数据: " + p1 + " p2: " + p2 + " p3: " + p3)
        })
        //带有返回值
        ipc.on('js-on-event-demo-return', function (p1, p2) {
            writeMessage("js-on-event-demo-return-Go传递过来的数据: " + p1 + " p2: " + p2)
            //该返回值将返回到go中
            return 'js返回的数据: ' + p1
        })
    </script>
</head>
<body style="margin: 0px;padding: 0px;">
JS中监听事件，Go中调用<br>
<div id="message"></div>
</body>
</html>